﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        #result {
            width: 200px;
            height: 100px;
            border: solid 1px #90b;
        }
    </style>
</head>
<body>
    <button>点击发送</button>
    <button>点击取消</button>

    <script>
        const btns = document.querySelectorAll('button');

        let x = null;
        btns[0].onclick = function () {
             x = new XMLHttpRequest();
            x.open('GET', 'http://127.0.0.1:8000/delay');
            x.send();
        }

        //abort 
        btns[1].onclick = function () {

            x.abort();
        }
    </script>
</body>
</html>